<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>机器人在线管理系统</title>
    <link href="https://lib.baomitu.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://lib.baomitu.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://lib.baomitu.com/layer/3.1.1/layer.js"></script>
    <link rel="stylesheet" href="https://lib.baomitu.com/layer/3.1.1/theme/default/layer.css?v=3.1.1"
          id="layuicss-layer">

<body background="https://www.cnblogs.com/skins/moonlightink/images/top.jpg">
<div class="container">
    <div class="col-xs-12 col-sm-10 col-md-8 col-lg-6 center-block" style="float: none;">
        <br>
        <div class="panel panel-primary">
            <div class="panel-heading" style="background: linear-gradient(to right,#b221ff,#14b7ff,#8ae68a);">
                <h3 class="panel-title">机器人在线管理系统</h3>
            </div>

            <span>数据运行时数据,机器人重启后将不会被保存，要永久保存请更改配置application.yml文件</span>
            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>机器人状态:</label>
                    <textarea id="robotStatus" cols="50" rows="10"></textarea>
                    <a onclick="robotStatus()" class="btn btn-primary">获取状态</a>
                    <a onclick="saveConf()" class="btn btn-primary">保存配置</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>群防闪照</label>
                    <select id="shazhao">
                        <option selected value="1">开</option>
                        <option value="0">关</option>
                    </select>
                    <a onclick="fsz()" class="btn btn-primary">修改</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>群防撤回</label>
                    <select id="chehui">
                        <option selected value="1">开</option>
                        <option value="0">关</option>
                    </select>
                    <a onclick="fch()" class="btn btn-primary">修改</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>自动同意加群</label>
                    <select id="addGroup">
                        <option selected value="1">开</option>
                        <option value="0">关</option>
                    </select>
                    <a onclick="agreeAddGroup()" class="btn btn-primary">修改</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>自动同意加友</label>
                    <select id="addFrend">
                        <option selected value="1">开</option>
                        <option value="0">关</option>
                    </select>
                    <a onclick="agreeAddFrend()" class="btn btn-primary">修改</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>修改机器人QQ</label>
                    <input id="robotQQ" type="number" maxlength="10">
                    <a onclick="setRobotQQ()" class="btn btn-primary">修改</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>群管号码</label>
                    <input id="qun" type="number" maxlength="15">
                    <a onclick="addQunMgr()" class="btn btn-primary">添加</a>
                    <a onclick="delQunMgr()" class="btn btn-primary">删除</a>
                </div>
            </div>


            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>修改机器人配置</label>
                    <br>
                    host:<input id="host" placeholder="机器人主机，不修改请留空"/><br>
                    token:<input id="token" placeholder="不修改请留空"/><br>
                    port:<input id="port" placeholder="机器人端口,不修改请留空"/><br>
                    <a onclick="modifyRobot()" class="btn btn-primary">修改</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>违禁词</label>
                    <textarea id="blackWord" rows="5"></textarea>
                    <a onclick="setBlackWord()" class="btn btn-primary">修改</a>
                </div>
            </div>

            <div class="list-group-item list-group-item-info" style="font-weight: bold;">
                <div class="list-group-item">
                    <label>主人QQ[禁言所需]</label>
                    <input id="owner">
                    <a onclick="modifyOwner()" class="btn btn-primary">修改</a>
                </div>
            </div>

        </div>


    </div>
</div>
<div class="panel panel-default text-center">
    <div class="panel-body">
        <a target="_blank" href="https://www.yeyusmile.top">Copyright © 夜雨小屋2021-2022</a>
    </div>
</div>
</div></div>

<script>


    function robotStatus() {
        $.get("/config/status", function (res) {
            $("#robotStatus").val(JSON.stringify(res, null, 4));
            $("#host").val(res.host);
            $("#token").val(res.token);
            $("#port").val(res.port);
            $("#robotQQ").val(res.robotQQ);
            $("#blackWord").val(res.blackWord);
            $("#owner").val(res.owners);
        });
    }

    robotStatus();


    function fsz() {
        var s = $("#shazhao").val();
        $.get("/config/flashPicSwitch?s=" + s, function (res) {
            alert(res);
        });

    }

    function fch() {
        var s = $("#chehui").val();
        $.get("/config/goBackcSwitch?s=" + s, function (res) {
            alert(res);
        });
    }

    function agreeAddGroup() {
        var s = $("#addGroup").val();
        $.get("/config/addGroupSwitch?s=" + s, function (res) {
            alert(res);
        });
    }

    function agreeAddFrend() {
        var s = $("#addFrend").val();
        $.get("/config/addFrendSwitch?s=" + s, function (res) {
            alert(res);
        });
    }

    function setRobotQQ() {
        var qq = $("#robotQQ").val();
        $.get("/config/setRobot?robot=" + qq, function (res) {
            alert(res);
        });
    }

    function addQunMgr() {
        var qun = $("#qun").val();
        $.get("/config/addGroupManger?group=" + qun, function (res) {
            alert(res);
        });
    }

    function delQunMgr() {
        var qun = $("#qun").val();
        $.get("/config/delGroupManger?group=" + qun, function (res) {
            alert(res);
        });
    }

    function modifyRobot() {
        var host = $("#host").val();
        var token = $("#token").val();
        var port = $("#port").val();

        $.get("/config/modify?port=" + port + "&token=" + token + "&host=" + host, function (res) {
            alert(res);
        });
    }

    function setBlackWord() {
        var w = $("#blackWord").val();
        var param = {blackWord: w}
        $.post("/config/modify", param, function (res) {
            alert(res);
        });
    }

    function modifyOwner() {
        var w = $("#owner").val();
        var param = {owners: w}
        $.post("/config/modify", param, function (res) {
            alert(res);
        });
    }

    function saveConf() {
        $.get("/config/save", function (res) {
            alert(res);
        });
    }

 /*    function readConf() {
        $.get("/config/read", function (res) {
            alert(res);
            robotStatus();
        });
    }*/







</script>

</body>
</html>